﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SMProject
{
    public partial class FrmBalance : Form
    {
        //构造方法
        public FrmBalance()
        {
            InitializeComponent();
        }

        public FrmBalance(string totalMoney)
        {
            InitializeComponent();

            //显示商品总金额
            this.lblTotalMoney.Text = totalMoney;
            this.txtRealReceive.Text = totalMoney;
            this.txtRealReceive.SelectAll();
            this.txtRealReceive.Focus();
        }

        //会员卡号回车键的处理
        private void txtMemberId_KeyDown(object sender, KeyEventArgs e)
        {
            if(e.KeyCode == Keys.Enter)  //如果是回车键，表示正常结算
            {
                if(this.txtMemberId.Text.Trim().Length == 0)
                {
                    this.Tag = this.txtRealReceive.Text.Trim();  //将实收款保存
                }
                else    //如果有会员卡，则将实收款和会员卡号同时返回
                {
                    //150|12345678
                    //判断该会员卡是否存在

                    //封装实收款和会员卡号
                    this.Tag = this.txtRealReceive.Text.Trim() + "|" + this.txtMemberId.Text.Trim();
                }
                this.DialogResult = DialogResult.OK;
            }
            else if (e.KeyCode == Keys.F4)  //F4：代表用户放弃所有商品的购买
            {
                this.Tag = "F4";
                this.Close();
            }
            else if (e.KeyCode == Keys.F5)  //F5：考虑用户钱不够，需要减掉一些商品
            {
                this.Tag = "F5";
                this.Close();
            }

        }
    }
}
